package mahi.collection;
import java.util.*;

public class NameSort {
    public static void main(String[] args) {
        Name nameArray[] = {
            new Name("John", "Smith",22),
            new Name("Karl", "Ng",41),
            new Name("Jeff", "Smith",19),
            new Name("Tom", "Rich", 21)
        };

        List<Name> names = Arrays.asList(nameArray);
        
        //Deafault ordering
        Collections.sort(names);
        System.out.println(names);
        
        
        
        
        
        
        
        
        
        
        
        
        
      
        
        Comparator<Name> ageComparator = new Comparator<Name>() {
			@Override
			public int compare(Name o1, Name o2) {
				return o1.age - o2.age;
			}
		};
		
		List<Name> namesExtra = Arrays.asList(nameArray);
		Collections.sort(namesExtra, ageComparator);
	    System.out.println(namesExtra);
		
    }
}